#ifndef __BASE_OBJECT_H__
#define __BASE_OBJECT_H__

#include "Poco/Thread.h"
#include "Poco/Runnable.h"

class BaseThread : public Poco::Runnable
{
public:
    enum NextLoop
    {
        NextLoop_Exit = -1,
        NextLoop_UseEvent = -2
    };
    BaseThread(bool bUseEvent);
    virtual void Start();
    virtual void Stop();
    bool IsRunning();
    void SetEvent();
    int WaitStop(int iTimeOut);

protected:
    virtual int SingleStep() = 0;

protected:
    void run();

private:
    Poco::Thread      m_thread;
    bool              m_bRunning;
    Poco::Event       m_event;
    bool              m_bUseEvent;
};

#endif //__BASE_OBJECT_H__
